/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.cef.variable.dtgenerator.core.rtgenerator.manager;


import com.inspur.edp.caf.generator.BaseGenerator;
import com.inspur.edp.caf.generator.composite.CompositeGeneratorContext;
import com.inspur.edp.cef.generator.coreGenerator.base.accessorcreatorgen.AccessorCreatorGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.mgrGenerator.DataManagerImplGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.mgrGenerator.ManagerGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.serializer.changeser.valueobject.ValueObjChangeSerGenerator;
import com.inspur.edp.cef.variable.dtgenerator.core.VariableCoreGenCtx;
import com.inspur.edp.cef.variable.dtgenerator.core.rtgenerator.entity.VarEntityGenerator;
import com.inspur.edp.cef.variable.dtgenerator.core.rtgenerator.manager.acccessorcreator.VarAccessorCreatorGenerator;
import java.util.ArrayList;

public class VarManagerGenerator extends ManagerGenerator {

  private VariableCoreGenCtx varGenCtx;

  public VarManagerGenerator(VariableCoreGenCtx parentContext) {
    super(parentContext);
    this.varGenCtx = parentContext;
  }

  protected VarMgrGenContext getVarMgrGenContext() {
    return (VarMgrGenContext) super.getContext();
  }

  @Override
  protected AccessorCreatorGenerator createAccessorCreatorImplGenerator() {
    return new VarAccessorCreatorGenerator(getVarMgrGenContext());
  }

  @Override
  protected final CompositeGeneratorContext createCompositeContext() {
    return CreateVarMgrGenCtx();
  }

  @Override
  protected VarMgrGenContext getContext(){return (VarMgrGenContext) super.getContext();}

  protected VarMgrGenContext CreateVarMgrGenCtx() {
    return new VarMgrGenContext(varGenCtx);
  }

  @Override
  protected EntityGenerator createEntityGenerator() {
    return new VarEntityGenerator( getContext());
  }

  @Override
  protected final DataManagerImplGenerator createMgrImplGenerator() {
    return createVarMgrImplGenerator();
  }

  protected VarManagerImplGenerator createVarMgrImplGenerator() {
    return new VarManagerImplGenerator(getContext());
  }

  @Override
  protected void addExtendCompositeItemGenerators(
      ArrayList<BaseGenerator> compositeItemGenerators) {
    super.addExtendCompositeItemGenerators(compositeItemGenerators);
    compositeItemGenerators.add(new ValueObjChangeSerGenerator(getVarMgrGenContext()));
  }
}
